/*
 * @Author: wangjinyan
 * @LastEditors: wangjinyan
 * @Date: 2022-09-18 12:45:39
 * @LastEditTime: 2022-11-02 17:55:09
 * @FilePath: \client_ts\assets\Scripts\base\Singleton.ts
 */


export default class Singleton 
{
	protected create():void{
        
	}

	clear(): void {
		(this.constructor as typeof Singleton)._instance = null;
	}

	private static _instance:Singleton = null;

	public static instance<T extends Singleton>(this:{new(...args:any[]):T} & typeof Singleton):T{
		if (this._instance == null) {
			this._instance = new this();
			this._instance.create();
		}

		return this._instance as T;
	}
}